package iterator.collegeDisplay.iterator;

import iterator.collegeDisplay.leaf.Department;

import java.util.ArrayList;
import java.util.Iterator;

public class InfoCollegeIterator implements Iterator {

    private ArrayList<Department> departmentArrayList;
    private int index = -1;

    public InfoCollegeIterator(ArrayList<Department> departmentArrayList) {
        this.departmentArrayList = departmentArrayList;
    }

    @Override
    public boolean hasNext() {
        if (index >= departmentArrayList.size() - 1) {
            return false;
        } else {
            index ++;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentArrayList.get(index);
    }
}
